package com.accessibleworlds.blind;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

/**
 * Describes a blind user menu item. 
 * 
 * @author Ayberk Özgür
 *
 */
public class BlindUserMenuItem {
	private Context context = null;
	private String itemName = null; //The item's spoken name.
	private Intent targetActivity = null; //The activity to go to when this item is selected.
	private boolean returnsResult = false;
	
	/**
	 * Creates a new item for a blind user menu.
	 * @param itemName The spoken name of this item.
	 * @param targetActivity An intent to a target activity when this item is selected.
	 */
	public BlindUserMenuItem(Context context, String itemName, Intent targetActivity, boolean returnsResult) {
		this.context = context;
		this.itemName = itemName;
		this.targetActivity = targetActivity;
		this.returnsResult = returnsResult;
	}

	/**
	 * Gets the spoken name of this item.
	 * @return The spoken name of this item
	 */
	public String getSpokenName(){
		return itemName;
	}
	
	/**
	 * Goes to this item's target activity.
	 */
	public void selectItem(){
		if(returnsResult)
			((Activity)context).startActivityForResult(targetActivity,0);
		else
			context.startActivity(targetActivity);
	}
}
